﻿// <copyright file="EslEcoSpace.cs" company="Codeplex project Eco.Contrib"> 
// The MIT License (MIT) 
// </copyright> 
// <author>Peter Buchmann</author> 

namespace Eco.Contrib
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using Eco.Handles;
    using Eco.Linq;
    using Eco.Services;
    using Eco.UmlCodeAttributes;

    /// <summary>
    /// ESLEcoSpace: EcoSpace used as internal EcoSpace within the ESLService
    /// </summary>
    [EcoSpace]
    [UmlTaggedValue("Eco.InitializeNullableStringsToNull", "true")]
    [UmlTaggedValue("Eco.GenerateMultiplicityConstraints", "true")]
    public partial class EslEcoSpace : Eco.Handles.DefaultEcoSpace
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="EslEcoSpace"/> class.
        /// </summary>
        public EslEcoSpace()
            : base()
        {
            this.InitializeComponent();
        }

        #region Eco Managed code
        /// <summary>
        /// Persist all changes to the domain objects.
        /// </summary>
        /// <remarks>
        /// This function persists all changes to the eco space, including object creation,
        /// object manipulation, changed associations and object deletions. After invoking this method
        /// all undo information is removed.
        /// If the application does not have any persistence layer defined the operation does nothing.
        /// </remarks>
        public void UpdateDatabase()
        {
            if ((Persistence != null) && (DirtyList != null))
            {
                Persistence.UpdateDatabaseWithList(DirtyList.AllDirtyObjects());
            }
        }
        
        /// <summary>
        /// Gets the type system provider.
        /// </summary>
        /// <returns>Type system provider of EcoSpace</returns>
        protected override ITypeSystemService GetTypeSystemProvider()
        {
            return EslEcoSpace.GetTypeSystemService();
        }
        #endregion

        // Add user written methods here
    }
}
